const NUMS: &str = "0123456789abcdef";

pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let v = num_str.split('(').collect::<Vec<_>>();
    let x = v[0];
    let a = v[1];
    let a = &a[0..(a.len() - 1)];
    let a = a
        .chars()
        .fold(0, |acc, c| acc * 10 + c as usize - '0' as usize);
    let b = to_base as usize;
    let mut x = x
        .chars()
        .fold(0, |acc, c| acc * a + NUMS.find(c).unwrap() as usize);
    let mut y = String::new();
    loop {
        y.push(NUMS.chars().nth((x % b) as usize).unwrap());
        x /= b;
        if x == 0 {
            break;
        }
    }
    y.chars().rev().collect::<String>()
}
